Conversation
|
Stonehearth is my favorite repl. |
lindacai1
left a comment
There was a problem hiding this comment.
Looks good overall
Though I'm not sure this is something we should be exposing to the user, even if it's hidden behind the enable_lua_console_hotkey config option. Seems dangerous to allow them to run arbitrary code without a sandbox. Maybe only enable this in developer builds?
ui/lua_console/lua_console.html
Outdated
| <script type="text/x-handlebars" data-template-name="luaConsoleIcon"> | ||
| <div id="luaConsoleIcon" title="Lua Console"></div> | ||
| </script> | ||
| <script type="text/x-handlebars" data-template-name="_toolbar"> |
There was a problem hiding this comment.
I'm guessing this isn't used? We should also remove the one in object_browser
ui/lua_console/lua_console.js
Outdated
| view.focus(); | ||
| } | ||
| } else { | ||
| App.debugView.addView(App.StonehearthLuaConsoleView) |
ui/lua_console/lua_console.less
Outdated
| position: absolute; | ||
| top: 9px; | ||
| left: 655px; | ||
| font-family: "Lucida Console", monospace; |
There was a problem hiding this comment.
Can you add Lucida Console to variables.less and access the font through there? We generally try to avoid using the font strings directly to avoid duplication.
There was a problem hiding this comment.
Switched to @debugFontFamily.
| -- let executed code set global vars. We could instead compile the expression as a | ||
| -- function with an entity argument, but if it's a statement, it won't be able to | ||
| -- normally set global vars, so no REPL state. | ||
| local saved_entity = rawget(_G, 'e') |
There was a problem hiding this comment.
I feel like naming the variable entity is more intuitive than e. e is less verbose though 🤔
There was a problem hiding this comment.
I started off with "entity", but after playing with it for a while, it was a pain to type that every time. I considered using something particularly weird like $ and replacing it with some auto-generated variable name in the script before compiling, but that seems worse,
There was a problem hiding this comment.
That's fair. Lets stick with e then
|
Also, thanks for doing this! This will be super helpful for debugging |
|
Thanks! This is appreciated. RepeatPan did something like this back in the day and it was useful, it helped me to debug some Candyland stuff with his help. |
This adds a console to interactively execute arbitrary Lua code on the client or server. It gives full read/write access to the global scope and also conveniently exposes the currently selected entity. The goal is to be able to interactively examine and prod game state during debugging.
Screenshot